package com.ppsea.work;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import com.pat.java.base.Test;
import com.ppsea.Utils;
public class Fxwr_FirstTongReward {

	/**
	 * 2014.02.24 fxwr 第一仙族战奖励发放
	 * @param args
	 */
	public static void main(String[] args) {
		
		int zoneId = 1;				//当前分区
		boolean isLocal = false;	//是否本地连接
		boolean isTest = false;		//测试开关
		
		//各族族长名单
		String tongMasterList = "C:\\Users\\smaller\\Desktop\\firstTongReward.txt";
		
		
		List<String> playerList = new ArrayList<String>();
		BufferedReader playersReader = null;
		try {
			playersReader = new BufferedReader(new InputStreamReader(new FileInputStream(tongMasterList)));
			
			
			String playerContent = playersReader.readLine();
			while(playerContent != null){
				playerList.add(playerContent);
				playerContent = playersReader.readLine();
			}
			playersReader.close();
			

			int index = 0;
			for(String playerId : playerList){
				int rank = ++index;
				
				String playerMainUrl = Test.getFxwrSpecialMarkbook(playerId, zoneId, isLocal, "p_M", "");
				
				//让玩家上线
				if(!isTest){
					Test.testHttpUrlConnection(playerMainUrl);
				}
				
				String domain = Utils.FXWR_XIAN;// old domain fxwr.3g.qq.com
				if (zoneId == 2) {
					domain = Utils.FXWR_MO;
				} else if (zoneId == 3) {
					domain = Utils.FXWR_HUAI;
				}
				if(isLocal){
					domain = "http://localhost:8080";
				}
				
				/*
				 * 第一家族奖励:<br/>
				 * 仙魔界：
				 * 1.第一家族族长获得天道令*1.(天道令用于6级提升为7级)<br/>
				 * 2.第一家族专属加成家族成员裸身全属性提高5%(气血上限、法力上限、攻击、防御),效果持续10天.<br/>
				 * 3.第一家族族长每日首次登陆给与全服提示,效果持续10天.<br/>
				 * 4.第一家族专属荣耀图标,家族成员公聊上均显示霸气专属小图标,效果持续30天<br/>
				 * 5.第1名:3阶七星石x1+1阶七星石x5+400仙族战功<br/>
				 *   第2名:1阶七星石x5+凤灵石x5+250仙族战功<br/>
				 *   第3名:1阶七星石x3+凤灵石x3+200仙族战功<br/>
				 *   第4~8名:1阶七星石x1+凤灵石x1+100仙族战功+50族战宝箱<br/>
				 *   
				 * 怀旧区：
				 *     1.第一家族族长获得天道令*1.(天道令用于6级提升为7级)<br/>
				 *     2.第一家族专属加成家族成员裸身全属性提高5%(气血上限、法力上限、攻击、防御),效果持续10天.<br/>
				 *     3.第一家族族长每日首次登陆给与全服提示,效果持续10天.<br/>
				 *     4.第一家族专属荣耀图标,家族成员公聊上均显示霸气专属小图标,效果持续30天<br/>
				 *     5.第1名:七星石x4+350仙族战功<br/>
				 *       第2名:七星石x3+250仙族战功<br/>
				 *       第3名:七星石x2+200仙族战功<br/>
				 *       第4~8名:七星石x1+100仙族战功<br/>
				 *       
				 *       天道令 30669
				 *       3阶七星石 30870
				 *       1阶七星石	30868
				 *       凤灵石	30943
				 *       50族战宝箱	30144
				 *       七星石	30858
				 */
				if(rank == 1){
					//第一名
					if(zoneId != 3){
						
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30669+"_"+1+"_1";
						String u2 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30870+"_"+1+"_1";
						String u3 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30868+"_"+5+"_1";
						String u4 = domain + "/admin?cmd=m_SA|"+playerId+"|1_400";
						
						System.out.println(u1);
						System.out.println(u2);
						System.out.println(u3);
						System.out.println(u4);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
							Test.testHttpUrlConnection(u3);
							Test.testHttpUrlConnection(u4);
						}
					}else{
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30858+"_"+4+"_1";
						String u2 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30669+"_"+1+"_1";
						String u3 = domain + "/admin?cmd=m_SA|"+playerId+"|1_350";
						
						System.out.println(u1);
						System.out.println(u2);
						System.out.println(u3);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
							Test.testHttpUrlConnection(u3);
						}
					}
				}else if(rank == 2){
					//第二名
					if(zoneId != 3){
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30868+"_"+5+"_1";
						String u2 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30943+"_"+5+"_1";
						String u3 = domain + "/admin?cmd=m_SA|"+playerId+"|1_250";
						
						System.out.println(u1);
						System.out.println(u2);
						System.out.println(u3);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
							Test.testHttpUrlConnection(u3);
						}
					}else{
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30858+"_"+3+"_1";
						String u2 = domain + "/admin?cmd=m_SA|"+playerId+"|1_250";
						
						System.out.println(u1);
						System.out.println(u2);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
						}
					}
				}else if(rank == 3 || rank == 4){
					//第3，4名
					if(zoneId != 3){
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30868+"_"+3+"_1";
						String u2 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30943+"_"+3+"_1";
						String u3 = domain + "/admin?cmd=m_SA|"+playerId+"|1_200";//m_SA|playerId|flag_num
						System.out.println(u1);
						System.out.println(u2);
						System.out.println(u3);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
							Test.testHttpUrlConnection(u3);
						}
					}else{
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30858+"_"+2+"_1";
						String u2 = domain + "/admin?cmd=m_SA|"+playerId+"|1_200";
						System.out.println(u1);
						System.out.println(u2);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
						}
					}
				}else if(rank >=5 && rank <= 8){
					//第5-8名
					if(zoneId != 3){
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30868+"_"+1+"_1";
						String u2 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30943+"_"+1+"_1";
						String u4 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30144+"_"+50+"_1";
						String u3 = domain + "/admin?cmd=m_SA|"+playerId+"|1_100";//m_SA|playerId|flag_num
						System.out.println(u1);
						System.out.println(u2);
						System.out.println(u3);
						System.out.println(u4);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
							Test.testHttpUrlConnection(u3);
							Test.testHttpUrlConnection(u4);
						}
					}else{
						String u1 = domain + "/admin?cmd=m_AI|"+playerId+"|"+30858+"_"+1+"_1";
						String u2 = domain + "/admin?cmd=m_SA|"+playerId+"|1_100";
						System.out.println(u1);
						System.out.println(u2);
						
						if(!isTest){
							Test.testHttpUrlConnection(u1);
							Test.testHttpUrlConnection(u2);
						}
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}